package com.算法.位运算;

public class 零到1间的浮点数二进制 {
    public static void main(String[] args) {
        // 0.01
        double a = 0.25;
        StringBuilder b = new StringBuilder("0.");
        while(a>0){
            //乘2，挪整
            double c = a * 2;
            if(c >= 1){
                b.append("1");
                a = c - 1;
            }else{
                b.append("0");
                a = c;
            }
            if (b.length()>34) {
                System.out.println("ERROR");
                return;
            }
        }
        System.out.println("b=>"+b.toString());
    }
}
